<template>
    <div>
        <div class="container">
            <div class="admin-index" v-if="loading == false">
                <div>
                    <div class="e-p-b-30" style="font-size: 18px;">库存表</div>
                    <el-radio-group v-model="dataType" class="e-m-b-45">
                        <el-radio-button label="0">数据中台</el-radio-button>
                        <el-radio-button label="1">库存表</el-radio-button>
                        <el-radio-button label="2">线上回收统计</el-radio-button>
                        <el-radio-button label="3">门店回收统计</el-radio-button>
                        <el-radio-button label="4">小哥入库统计</el-radio-button>
                        <el-radio-button label="5">出库销售统计</el-radio-button>
                    </el-radio-group>
                </div>
                <div>
                    <el-form :inline="true" class="demo-form-inline">
                        <el-form-item label="站点筛选">
                            <!-- <el-select v-model="storeId" clearable placeholder="请选择" @change="changeStore">
                                <el-option v-for="item in StoreList" :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select> -->

                            <storeList v-model="storeId" @change="changeStore"></storeList>
                        </el-form-item>
                        <!-- <el-form-item>
							<el-button type="primary" @click="getlist">查询</el-button>
						</el-form-item> -->
                        <el-form-item>
                            <el-button @click="downloadwithdrawa()" style="margin-bottom:30px; margin-top: 1px;"
                                type="primary" plain><i class="iconfont icon-excel"></i>导出Excel</el-button>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="flex">
                    <!-- <div class="e-w-300 e-m-t-20">
						<el-tree :data="dataTree" show-checkbox node-key="id" :default-expanded-keys="[2, 1]"
							:default-checked-keys="[4,5]" :props="defaultProps">
						</el-tree>
					</div> -->
                    <div class="e-flex-1">
                        <!-- <div class="flex align-items-center">
							<h4 class="e-m-0">海景花园便民点库存 2024年7月30日14:30:57</h4>
							<span class="tips e-font-12 e-m-l-15">最近盘点：2024年7月28日14:30:57，盘亏100元</span>
						</div> -->

                        <!-- 库存表组件 -->
                        <!-- <inventory-table :store-id="storeId"></inventory-table> -->

                        <!-- 库存总览 -->
                        <stock-overview :store-id="storeId"></stock-overview>
                    </div>
                    <!-- <div v-else style="width: 100%;">
                        <el-empty description="请选择站点查看"></el-empty>
                    </div> -->
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import storeList from '@/components/form-select-type/storeList.vue'
export default {
    layout: 'admin',
    components: {
        storeList
    },
    head() {
        return {
            title: '库存详情'
        }
    },
    data() {
        return {
            dataType: 1,
            loading: false,
            tableData: [],
            storeId: null,
            // StoreList: '',
            // dataTree: [
            // 	{
            // 		id: 0,
            // 		label: '全部',
            // 		children:[
            // 			{
            // 			id: 1,
            // 			label: '已入库全部(已选1个回收点)',
            // 			children: [{
            // 					id: 4,
            // 					label: '站点1号',
            // 					children: []
            // 				},{
            // 					id: 9,
            // 					label: '站点2号'
            // 				}, {
            // 					id: 10,
            // 					label: '站点3号'
            // 				}]
            // 			}, 
            // 			{
            // 				id: 2,
            // 				label: '未入库全部(已选1个小哥)',
            // 				children: [{
            // 					id: 5,
            // 					label: '小哥1'
            // 				}, {
            // 					id: 6,
            // 					label: '小哥2'
            // 				}]
            // 			}
            // 		]
            // 	}
            // ],
            // defaultProps: {
            // 	children: 'children',
            // 	label: 'label'
            // }
        };
    },
    watch: {
        dataType(val) {
            console.log(val)
            let type = Number(val)
            switch (type) {
                case 0:
                    this.$router.push({
                        path: '/'
                    })
                    break;
                case 1:
                    this.$router.push({
                        path: '/statistics/inventory'
                    })
                    break;
                case 2:
                    this.$router.push({
                        path: '/statistics/online'
                    })
                    break;
                case 3:
                    this.$router.push({
                        path: '/statistics/store'
                    })
                    break;
                case 4:
                    this.$router.push({
                        path: '/statistics/onlinestorage'
                    })
                    break;
                case 5:
                    this.$router.push({
                        path: '/statistics/storeSell'
                    })
                    break;
            }
        }
    },
    mounted() {
        // this.getstorelist()
    },
    methods: {
        changeStore() {
            // this.loading = true
            // setTimeout(() => {
            // 	this.loading = false
            // }, 500)
        },
        downloadwithdrawa() {
            this.$axios.post('/Statistics/StockOverview/Download', {
                storeIds: [this.storeId]
            }, {
                responseType: 'blob'
            }).then(res => {
                console.log(res)
                let content = res;
                let fileName = '库存表.xls'
                this.utils.saveAndExport(content, fileName)
            })
        },
        // getstorelist() {
        //     this.$axios.post('/Select/StoreList', {
        //         "pageIndex": 1,
        //         "pageSize": 999,
        //     }).then((res) => {
        //         console.log(res)
        //         this.StoreList = res.rows
        //         // this.StoreList.unshift({
        //         // 	id: "",
        //         // 	name: '全部'
        //         // })
        //     }).catch((err) => {
        //         this.loading = false
        //     })
        // },
    }
};
</script>
<style lang="scss" scoped></style>